package com.luban.springboot10.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.luban.springboot10.pojo.User;

@Mapper
public interface UserDaoTwo {
	
	 /**
	  * 删除	
	  * @param id
	  * @return
	  */
	 @Delete("delete from s_user where id = #{id}")
	 int deleteByPrimaryKey(Integer id);

	 /**
	  * 新增
	  * @param record
	  * @return
	  */
	 @Insert("insert into s_user (id, type, user_name) values ( #{id}, #{type}, #{userName})")
	 int insert(User record);

	 /**
	  * 查询
	  * @param id
	  * @return
	  */
	 @Select("select id, type, user_name  from s_user where id = #{id}")
	 @Results({//注意：property 对应实体类字段  column对应数据库字段
		 @Result(property = "type", column = "type"),@Result(property = "userName", column = "user_name")
	 })
	 User selectByPrimaryKey(Integer id);

	 /**
	  * 修改
	  * @param record
	  * @return
	  */
	 @Update(" update s_user set type = #{type},user_name = #{userName} where id = #{id}")
	 int updateByPrimaryKey(User record);
}
